﻿using GrainManage.Base;
using GrainManage.Entities.Image;
using GrainManage.Api;
using GrainManage.Proxy;

namespace GrainManage.Pages
{
    /// <summary>
    /// Interaction logic for MultiMediaPage.xaml
    /// </summary>
    public partial class ImagePage : BasePage
    {
        public ImagePage()
        {
            InitializeComponent();

            myPager.RegisterService((pageIndex, pageSize) =>
            {
                TryBeginInvoke(() =>
                {
                    var input = new InputGetImages
                    {
                        Authentication = App.Authentication,
                        PageIndex = pageIndex,
                        PageSize = pageSize
                    };
                    return Creator.ImageProxy.GetImages(input);
                }, (result) =>
                {
                    UI.ShowContent(listview, result.Images);
                    myPager.TotalRowCount = result.Total;
                });
            }, ImageApi.GetImages);
            myPager.StartService(ImageApi.GetImages);
        }
    }
}
